package com.mj.hotel.mvp.ui.fragment;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import com.jess.arms.base.BaseFragment;
import com.jess.arms.di.component.AppComponent;
import com.mj.hotel.R;
import com.mj.hotel.mvp.ui.adapter.CustomPagerAdapter;
import com.mj.hotel.mvp.ui.event.ChangeFragmentMsg;
import com.viewpagerindicator.CirclePageIndicator;

import org.simple.eventbus.EventBus;

import butterknife.BindView;

public class SplashFragment extends BaseFragment {

    @BindView(R.id.goHome)
    public Button goHome;

    @BindView(R.id.splashVp)
    public ViewPager splashVp;
    @BindView(R.id.indicator)
    public CirclePageIndicator indicator;

    private PagerAdapter adapter;


    @Override
    public void setupFragmentComponent(@NonNull AppComponent appComponent) {

    }

    @Override
    public View initView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_splash, container, false);
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        goHome.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View v) {
                EventBus.getDefault().post(ChangeFragmentMsg.getInstance(HomeFragment.class.getSimpleName()));
            }
        });
        adapter = new CustomPagerAdapter(mContext);
        splashVp.setAdapter(adapter);
        indicator.setViewPager(splashVp);
    }

    @Override
    public void setData(@Nullable Object data) {

    }
}
